﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Kopytko
{
    /// <summary>
    /// Interaction logic for WindowButtons.xaml
    /// </summary>
    public partial class WindowButtons : UserControl
    {


        public Window AssociatedWindow
        {
            get { return (Window)GetValue(AssociatedWindowProperty); }
            set { SetValue(AssociatedWindowProperty, value); }
        }

        // Using a DependencyProperty as the backing store for AssociatedWindow.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty AssociatedWindowProperty =
            DependencyProperty.Register("AssociatedWindow", typeof(Window), typeof(WindowButtons), new UIPropertyMetadata(null));



        public WindowButtons()
        {
            InitializeComponent();
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            if (AssociatedWindow!=null)
            {
                AssociatedWindow.Close();
            }
        }

        private void MaximizeButton_Click(object sender, RoutedEventArgs e)
        {
            if (AssociatedWindow != null)
            {
                if (AssociatedWindow.WindowState != WindowState.Maximized)
                {
                    AssociatedWindow.WindowState = WindowState.Maximized;
                }
                else
                {
                    AssociatedWindow.WindowState = WindowState.Normal;
                }
            }
        }

        private void MinimalizeButton_Click(object sender, RoutedEventArgs e)
        {
            if (AssociatedWindow != null)
            {
                AssociatedWindow.WindowState = WindowState.Minimized;
            }
        }
    }
}
